package com.uu.look.web;


import com.uu.look.web.filter.SessionFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.annotation.Order;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.servlet.Filter;
import javax.servlet.MultipartConfigElement;


/**
 * User : LiuKe
 * Date : 2017/1/11
 * Time : 10:11
 */
@EnableTransactionManagement
@SpringBootApplication
@ComponentScan(basePackages = {"org.uu.skull","com.kg.ems.store.web","com.kg.ems.store.common","com.kg.ems.store.data","com.kg.ems.store.service"})
public class Application extends SpringBootServletInitializer {

    //war包部署必须
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(3* 1024 * 1024L);
        return factory.createMultipartConfig();
    }

    @Bean
    @Order(10)
    Filter sessionFilter() {
        return new SessionFilter();
    }

}
